A good starting point for understanding QuickTime for Java is the QTSimpleApplet program, a code snippet of which is shown in Example 0.1 . This program is useful for taking advantage of QuickTime presentation on the Internet to display multimedia content--and this is accomplished in less than a dozen lines of Java code. Figure 1 shows the output of the QTSimpleApplet , running locally on the user's computer in an Internet Explorer browser window. The resulting QuickTime movie, which you can control with the standard QuickTime movie controller buttons, uses the media as specified in the applet tag--in this case, sample.mov .
The QTSimpleApplet example uses QTFactory() methods that belong to the quicktime.app package to manufacture QuickTime objects that are able to present any of the wide range of media that QuickTime supports. That media may include video, audio, text, timecode, music/MIDI, sprite animation, tween, MPEG, or even movies that let you use Apple's QuickTime VR and QuickDraw 3D capabilities. The code sample is discussed in detail in "The QTSimpleApplet Code" .
public class QTSimpleApplet extends Applet {
private Drawable myQTContent;
private QTCanvas myQTCanvas;
public void init () {
try {
QTSession.open();
setLayout (new BorderLayout());
myQTCanvas = new QTCanvas (QTCanvas.kInitialSize, 0.5F, 0.5F);
add (myQTCanvas, "Center");
QTFile file = new QTFile (getCodeBase().getFile() + getParameter("file"));
myQTContent = QTFactory.makeDrawable (file);
} catch (Exception qtE) {
...
// handle exception
}
}
public void start () {
try {
if (myQTCanvas != null)
myQTCanvas.setClient (myQTContent, true);
} catch (QTException e) {
}
}
public void stop () {
if (myQTCanvas != null)
myQTCanvas.removeClient();
}
public void destroy () {
QTSession.close();
}
}
Figure 1 The QTSimpleApplet running in a browser window
| Previous | Chapter Top | Next |